package httpresponse

import "myginblog/utils/errmsg"

type ResponseBody struct {
	Code int
	Msg  string
	Data interface{}
}

func SetResponseBody(code int, msg string, data interface{}) ResponseBody {
	if msg == "" {
		if data == nil {
			return ResponseBody{
				Code: code,
				Msg:  errmsg.GetErrmsg(code),
			}
		}
		return ResponseBody{
			Code: code,
			Msg:  errmsg.GetErrmsg(code),
			Data: data,
		}
	}

	return ResponseBody{
		Code: code,
		Msg:  msg,
		Data: data,
	}
}
